﻿namespace Community.CsharpSqlite.Entity
{
    /*
     ** An instance of the following structure stores a database schema.
     **
     ** If there are no virtual tables configured in this schema, the
     ** Schema.db variable is set to NULL. After the first virtual table
     ** has been added, it is set to point to the database connection
     ** used to create the connection. Once a virtual table has been
     ** added to the Schema structure and the Schema.db variable populated,
     ** only that database connection may use the Schema to prepare
     ** statements.
     */

    public class Schema
    {
        public int schema_cookie; /* Database schema version number for this file */
        public Hash tblHash = new Hash(); /* All tables indexed by name */
        public Hash idxHash = new Hash(); /* All (named) indices indexed by name */
        public Hash trigHash = new Hash(); /* All triggers indexed by name */
        public Hash fkeyHash = new Hash(); /* All foreign keys by referenced table name */
        public Table pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
        public byte file_format; /* Schema format version for this file */
        public byte enc; /* Text encoding used by this database */
        public ushort flags; /* Flags associated with this schema */
        public int cache_size; /* Number of pages to use in the cache */
#if !SQLITE_OMIT_VIRTUALTABLE
public   sqlite3 db;                    /* "Owner" connection. See comment above */
#endif

        public Schema Copy()
        {
            if (this == null)
                return null;
            else
            {
                var cp = (Schema) MemberwiseClone();
                return cp;
            }
        }
    };
}